/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package course.services;

import java.io.Serializable;
import java.security.Principal;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;

/**
 *
 * @author def
 */
@ManagedBean(name = "userSession", eager = true)
@SessionScoped
public class UserSession extends AUserService implements Serializable {
    
    private static final long serialVersionUID = -780324353394721L;
    
    public boolean isLogged() {
        ExternalContext context = FacesContext.getCurrentInstance().getExternalContext();
        Principal principal = context.getUserPrincipal();
        if(principal != null) {
            return true;
        }
        return false;
    }
}
